package com.example.warehouse.service.serviceImpl;

import com.example.warehouse.entity.Product;
import com.example.warehouse.mapper.ProductMapper;
import com.example.warehouse.page.Page1;
import com.example.warehouse.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductMapper productMapper;
    @Override
    public Page1 pageGet(Page1 page1, Product product) {
        Integer countPage = productMapper.getCountPage(product);
        List<Product> productList = productMapper.findproductPage(page1, product);
        page1.setTotalNum(countPage);
        page1.setResultList(productList);
        return page1;
    }

    @Override
    public void insertProduct(Product product) {
        productMapper.addProduct(product);
    }

    @Override
    public void updateState(Product product) {
        productMapper.updateState(product.getProductId(),product.getUpDownState());
    }

    @Override
    public void updateProduct(Product product) {
        productMapper.updateProduct(product);
    }

    @Override
    public void deleteList(List<Integer> deleteList) {
        productMapper.deleteList(deleteList);
    }
}
